package com.week.config;

import com.rabbitmq.client.Channel;
import com.week.entity.UserLogin;
import com.week.feign.SysUserFeign;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
@Log4j2
public class SysQueue {





    @Bean
    public Queue SysQueue(){
        return new Queue("sys_user",true);
    }
    @RabbitListener(queues ={"sys_user"})
    public void SysSendMsg(Integer uid, Message message, Channel channel){
      try {
       log.info("用户消息登录队列:{},接收到的消息:{}","sys_user",uid);
          UserLogin login = new UserLogin();
          login.setId(uid);
          System.out.println(message);
          System.out.println(login);
          System.out.println(uid);

          channel.basicAck(message.getMessageProperties().getDeliveryTag(),true);
      }catch (Exception e){

      }
    }
}
